<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Compressore e decompressore di Huffman: Riferimenti per il file Huffman.cc</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Compressore e decompressore di Huffman
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generato da Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Cerca');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Pagina&#160;Principale</span></a></li>
      <li><a href="annotated.html"><span>Classi</span></a></li>
      <li class="current"><a href="files.html"><span>File</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Cerca" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Elenco&#160;dei&#160;file</span></a></li>
      <li><a href="globals.html"><span>Elementi&#160;dei&#160;file</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#func-members">Funzioni</a> &#124;
<a href="#var-members">Variabili</a>  </div>
  <div class="headertitle">
<div class="title">Riferimenti per il file Huffman.cc</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;iostream&gt;</code><br/>
<code>#include &lt;gtk/gtk.h&gt;</code><br/>
<code>#include &lt;cstring&gt;</code><br/>
<code>#include &lt;sstream&gt;</code><br/>
<code>#include &quot;<a class="el" href="struttura__dati_8h_source.html">struttura_dati.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="comprimi_8h_source.html">comprimi.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="decomprimi_8h_source.html">decomprimi.h</a>&quot;</code><br/>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Funzioni</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Huffman_8cc.html#a25880d9d561c0b54301ba567d445c40f">hide_main_window</a> (GtkButton *button, gpointer data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Segnale che chiude la finestra in cui si trova il pulsante premuto.  <a href="#a25880d9d561c0b54301ba567d445c40f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Huffman_8cc.html#a60067450966ffe729e2a3d5d1a8ad61e">handler_comprimi</a> (GtkButton *button, gpointer data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">segnale che gestisce l'evento click del pulsante comprimi apre la finestra di dialogo adibita al salvataggio  <a href="#a60067450966ffe729e2a3d5d1a8ad61e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Huffman_8cc.html#a6928b9a981906b8dd5582608d5c9192f">handler_decomprimi</a> (GtkButton *button, gpointer data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">segnale che gestisce l'evento click del pulsante decomprimi questo segnale apre un finestra di dialogo dove poter salvare e dare un nome al file che si crea con le decompressione controlla inoltre che l'utente abbia selezionato un file .huf per da decomprimere  <a href="#a6928b9a981906b8dd5582608d5c9192f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Huffman_8cc.html#a13f4d10adeddb278e464791fb5086cf6">handler_scegli_op</a> (GtkButton *button, gpointer data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">segnale paragonbile a un front-end permette di decidere quale operazione eseguire se la compressione o la decompressione del file  <a href="#a13f4d10adeddb278e464791fb5086cf6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Huffman_8cc.html#a6b54ebb4c3a525965810aa404a9e6b3a">handler_carica_documentazione</a> (GtkMenuItem *item, gpointer data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">link alla documentazione  <a href="#a6b54ebb4c3a525965810aa404a9e6b3a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Huffman_8cc.html#a0ddf1224851353fc92bfbff6f499fa97">main</a> (int argc, char *argv[])</td></tr>
<tr><td colspan="2"><h2><a name="var-members"></a>
Variabili</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">GtkBuilder *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a></td></tr>
</table>
<hr/><h2>Documentazione delle funzioni</h2>
<a class="anchor" id="a6b54ebb4c3a525965810aa404a9e6b3a"></a><!-- doxytag: member="Huffman.cc::handler_carica_documentazione" ref="a6b54ebb4c3a525965810aa404a9e6b3a" args="(GtkMenuItem *item, gpointer data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="Huffman_8cc.html#a6b54ebb4c3a525965810aa404a9e6b3a">handler_carica_documentazione</a> </td>
          <td>(</td>
          <td class="paramtype">GtkMenuItem *&#160;</td>
          <td class="paramname"><em>item</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpointer&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>link alla documentazione </p>
<div class="fragment"><pre class="fragment">{
        <span class="comment">//system(&quot;firefox </span>
}
</pre></div>
</div>
</div>
<a class="anchor" id="a60067450966ffe729e2a3d5d1a8ad61e"></a><!-- doxytag: member="Huffman.cc::handler_comprimi" ref="a60067450966ffe729e2a3d5d1a8ad61e" args="(GtkButton *button, gpointer data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="Huffman_8cc.html#a60067450966ffe729e2a3d5d1a8ad61e">handler_comprimi</a> </td>
          <td>(</td>
          <td class="paramtype">GtkButton *&#160;</td>
          <td class="paramname"><em>button</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpointer&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>segnale che gestisce l'evento click del pulsante comprimi apre la finestra di dialogo adibita al salvataggio </p>
<div class="fragment"><pre class="fragment">{       
        gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;mex_esegui&quot;</span>)),<span class="stringliteral">&quot;Comprimi&quot;</span>);
        gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;msg&quot;</span>)),<span class="stringliteral">&quot;scegli dove salvare e il nome del file compresso&quot;</span>);
        
        gchar *sorg=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data));
        <span class="keywordflow">if</span>(sorg==NULL)
        {               
                mostra_messaggi(<span class="keyword">false</span>,1);
                <span class="keywordflow">return</span>;
        }
        GtkWidget *salvataggio=GTK_WIDGET(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;salva&quot;</span>));
        gtk_widget_show_all(salvataggio);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a6928b9a981906b8dd5582608d5c9192f"></a><!-- doxytag: member="Huffman.cc::handler_decomprimi" ref="a6928b9a981906b8dd5582608d5c9192f" args="(GtkButton *button, gpointer data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="Huffman_8cc.html#a6928b9a981906b8dd5582608d5c9192f">handler_decomprimi</a> </td>
          <td>(</td>
          <td class="paramtype">GtkButton *&#160;</td>
          <td class="paramname"><em>button</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpointer&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>segnale che gestisce l'evento click del pulsante decomprimi questo segnale apre un finestra di dialogo dove poter salvare e dare un nome al file che si crea con le decompressione controlla inoltre che l'utente abbia selezionato un file .huf per da decomprimere </p>
<div class="fragment"><pre class="fragment">{
        gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;mex_esegui&quot;</span>)),<span class="stringliteral">&quot;Decomprimi&quot;</span>);
        gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;msg&quot;</span>)),<span class="stringliteral">&quot;scegli dove salvare e il nome del file decompresso&quot;</span>);
        
        gchar *sorg=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data));
        <span class="keywordflow">if</span>(sorg==NULL)
        {               
                mostra_messaggi(<span class="keyword">false</span>,0);
                <span class="keywordflow">return</span>;
        }
        GtkWidget *salvataggio=GTK_WIDGET(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;salva&quot;</span>));
        gtk_widget_show_all(salvataggio);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a13f4d10adeddb278e464791fb5086cf6"></a><!-- doxytag: member="Huffman.cc::handler_scegli_op" ref="a13f4d10adeddb278e464791fb5086cf6" args="(GtkButton *button, gpointer data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="Huffman_8cc.html#a13f4d10adeddb278e464791fb5086cf6">handler_scegli_op</a> </td>
          <td>(</td>
          <td class="paramtype">GtkButton *&#160;</td>
          <td class="paramname"><em>button</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpointer&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>segnale paragonbile a un front-end permette di decidere quale operazione eseguire se la compressione o la decompressione del file </p>
<div class="fragment"><pre class="fragment">{
        GtkLabel *label=GTK_LABEL(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;mex_esegui&quot;</span>));
        <span class="keyword">const</span> <span class="keywordtype">char</span> *testo=gtk_label_get_text(label);
        <span class="keywordflow">if</span>(strcmp(testo,<span class="stringliteral">&quot;Comprimi&quot;</span>)==0)
                effettua_compressione(data);
        <span class="keywordflow">else</span>
                effettua_decompressione(data);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a25880d9d561c0b54301ba567d445c40f"></a><!-- doxytag: member="Huffman.cc::hide_main_window" ref="a25880d9d561c0b54301ba567d445c40f" args="(GtkButton *button, gpointer data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="Huffman_8cc.html#a25880d9d561c0b54301ba567d445c40f">hide_main_window</a> </td>
          <td>(</td>
          <td class="paramtype">GtkButton *&#160;</td>
          <td class="paramname"><em>button</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpointer&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Segnale che chiude la finestra in cui si trova il pulsante premuto. </p>
<div class="fragment"><pre class="fragment">{
        gtk_widget_hide(gtk_widget_get_toplevel(GTK_WIDGET(button)));
}
</pre></div>
</div>
</div>
<a class="anchor" id="a0ddf1224851353fc92bfbff6f499fa97"></a><!-- doxytag: member="Huffman.cc::main" ref="a0ddf1224851353fc92bfbff6f499fa97" args="(int argc, char *argv[])" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="Huffman_8cc.html#a0ddf1224851353fc92bfbff6f499fa97">main</a> </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>argc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>argv</em>[]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>inizializzazione gtk</p>
<p>aggiunga interfaccia grafica grafica.glade</p>
<p>aggiunta dei filtri per la selzione dei file ai filechooser, i filtri sono stati creati tramite glade qui avviene solo il settaggio del relativo nome e l'aggangio dei filtri ai filechooser</p>
<p>primo filtri riferito al chooser del compressore rende selezionabili solo i file con estensione .txt</p>
<p>secondo filtro riferito al chooser del decompressore rende selezionabili solo i file con estensione .huf</p>
<p>aggancio primo filtro</p>
<p>agggancio secondo filtro</p>
<p>conessione dei segnali con l'interfaccia</p>
<p>loop principale </p>
<div class="fragment"><pre class="fragment">                               {


        gtk_init(&amp;argc,&amp;argv);
        
        <a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>=gtk_builder_new();
        
        gtk_builder_add_from_file(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;grafica.glade&quot;</span>,NULL);
        
        GtkFileFilter *filtro=GTK_FILE_FILTER(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;filtro_file&quot;</span>));
        gtk_file_filter_set_name(filtro,<span class="stringliteral">&quot;.txt&quot;</span>);
        
        GtkFileFilter *filtro_dec=GTK_FILE_FILTER(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;filtro_file2&quot;</span>));
        gtk_file_filter_set_name(filtro_dec,<span class="stringliteral">&quot;*.huf&quot;</span>);
        
        GtkFileChooser *chooser=GTK_FILE_CHOOSER(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;chooser_compressore&quot;</span>));
        gtk_file_chooser_add_filter(chooser,filtro);
        
        GtkFileChooser *chooser_dec=GTK_FILE_CHOOSER(gtk_builder_get_object(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,<span class="stringliteral">&quot;chooser_decompressore&quot;</span>));
        gtk_file_chooser_add_filter(chooser_dec,filtro_dec);
        
        
        gtk_builder_connect_signals(<a class="code" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a>,NULL);
        
        gtk_main();

        <span class="keywordflow">return</span> 0;
        <span class="comment">//return (static_cast&lt;int&gt;(c1 &amp;&amp; c2));</span>
}
</pre></div>
</div>
</div>
<hr/><h2>Documentazione delle variabili</h2>
<a class="anchor" id="afa501dbb63ae6077ac8db76b560de42b"></a><!-- doxytag: member="Huffman.cc::builder" ref="afa501dbb63ae6077ac8db76b560de42b" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">GtkBuilder* <a class="el" href="Huffman_8cc.html#afa501dbb63ae6077ac8db76b560de42b">builder</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
</div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>Tutto</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classi</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>File</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Funzioni</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variabili</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Ridefinizioni di tipo (typedef)</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Tipi enumerati (enum)</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Valori del tipo enumerato</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Definizioni</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generato Mer 3 Lug 2013 15:17:47 per Compressore e decompressore di Huffman da &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
